/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package myftp.app.form;

import java.util.HashMap;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

/**
 *
 * @author CAVARLE Glenn, LUCAS Stéphane
 */
public class ConnectForm {

    public JLabel hostLabel = new JLabel("Hôte : ");
    public JLabel loginLabel = new JLabel("Identifiant :");
    public JLabel passwdLabel = new JLabel("Mot de passe :");
    public JLabel portLabel = new JLabel("Port :");

    public JTextField hostField = new JTextField("", 11);
    public JTextField loginField = new JTextField("", 10);
    public JTextField passwdField = new JPasswordField("", 10);
    public JTextField portField = new JTextField("21", 5);

    public HashMap<String, String> toMap() {
        HashMap<String, String> info = new HashMap();
        info.put("host", hostField.getText());
        info.put("login", loginField.getText());
        info.put("password", passwdField.getText());
        info.put("port", portField.getText());

        return info;
    }

    public boolean isValid() {
        String hostname = this.hostField.getText();
        if (hostname.startsWith("ftp://")) {
            this.hostField.setText(hostname.substring(6));
        }
        return !this.hostField.getText().equals("");
    }
}
